<template>
  <div class="nav2">
    <div class="container pt-4">
      <div class="row">
        <div class="col-12">
          <div class="pointsRule">
            <ul id="list">
              <li style="z-index:6;background-image: linear-gradient(to right, #005bea ,#00c6fb)" class="green" @click="gotoHome()"><a><span>首页</span><i style="background-color:#00c6fb"></i></a></li>
              <li style="z-index:5;background-image: linear-gradient(to right, #005bea ,#00c6fb)"  @click="gotoNav()"><a><em class="before"></em><span>预算管理</span><i style="background-color:#00c6fb"></i></a></li>
              <li style="z-index:4;background-image: linear-gradient(to right, #005bea ,#00c6fb)"  @click="$router.push('/nav3')"><a><em class="before"></em><span>预算编制</span><i style="background-color:#00c6fb"></i></a></li>
              <li style="z-index:3;background-image: linear-gradient(to right, #005bea ,#00c6fb)"  @click="$router.push('/nav1')"><a><em class="before"></em><span>制定目标(2021)</span><i style="background-color:#00c6fb"></i></a></li>
              <li style="z-index:1;background-color: #ffc107;"><a><em class="before"></em><span style="color: #4e555b;">年度</span><i style="background-color:#ffc107;"></i></a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="content">
      <ul class="pl-0">
        <li class="text-center">
          <router-link to="/nav5">费用</router-link>
        </li>
        <li class="text-center">
          <router-link  :to="{ path: '/nav6/年/其他'}">收入</router-link>
        </li>
<!--        <li class="text-center info">-->
<!--          <router-link to="">-->
<!--            <div>利润目标值：{{fixNum(incomeTargetAmount - costTarget - costTargetAmount)}}万元</div>-->
<!--            <div>收入：{{fixNum(incomeTargetAmount)}}万元</div>-->
<!--            <div>成本：{{fixNum(costTarget)}}</div>-->
<!--            <div>收入率：{{percentNum((incomeTargetAmount - costTarget) / incomeTargetAmount)}}%</div>-->
<!--            <div>费用：{{fixNum(costTargetAmount)}}万元</div>-->
<!--          </router-link>-->
<!--        </li>-->
        <!--<li class="text-center">-->
          <!--<router-link  to="/file">利润</router-link>-->
        <!--</li>-->
      </ul>
    </div>
  </div>
</template>

<script>
  export default {
    name: "nav2",
    data () {
      return {
        costNowMonth: 0,  //当月费用
        incomeNowMonth: 0,  //当月收入
        costTargetAmount: 0,
        incomeTargetAmount: 0,
        costAmount: 0,  //累积费用
        incomeAmount: 0, //累积收入
        loading: {},
        income: 0,
        incomeTarget: 0,
        cost: 0,
        costTarget: 0,
        orgid: window.sessionStorage.getItem('orgid')
      }
    },
    created() {
      this.getAllCost()
      this.getAllIncome()
      this.getAllProfit()
    },
    methods: {
      getAllCost(){
        // this.loading = this.$loading({
        //   lock: true,//lock的修改符--默认是false
        //   text: 'Loading',//显示在加载图标下方的加载文案
        //   spinner: 'el-icon-loading',//自定义加载图标类名
        //   background: 'rgba(0, 0, 0, 0.7)',//遮罩层颜色
        //   target: document.querySelector('#table')//loadin覆盖的dom元素节点
        // });
        this.$http.get(
          '/api/getCostSum',
          {
            params: {
              type: 3 + this.orgid
            }
          }).then(res => {
          this.costAmount = res.data.sumAmount
          this.costTargetAmount = res.data.targetAmount
          // this.loading.close()
        })
      },
      getAllIncome(){
        this.$http.get(
          '/api/getCostSum',
          {
            params: {
              type: 1 + this.orgid
            }
          }).then(res => {
          this.incomeAmount = res.data.sumAmount
          this.incomeTargetAmount = res.data.targetAmount
          // this.loading.close()
        })
      },
      getAllProfit () {
        this.$http.get(
          '/api/getCostSum',
          {
            params: {
              type: 4 + this.orgid
            }
          }).then(res => {
          this.cost = res.data.sumAmount
          this.costTarget = res.data.targetAmount
          // this.loading.close()
        })
      },
      fixNum (num) {
        return (num/10000).toFixed(2)
      },
      percentNum (num) {
        return (num * 100).toFixed(2)
      },
      gotoHome(){
        this.$router.push("/index");
      },
      //跳转到书吧
      gotoNav: function(){
        this.$router.push("/nav2");
      },
      init(income, cost){
        if (income === 0 || cost === 0) {
          return 0
        }else {
          const data = (income - cost) / income
          if (data < 100){
            return parseFloat(data).toFixed(2) + '元'
          }else {
            return this.fixNum(data) + '万元'
          }
        }
      }
    }
  }
</script>

<style scoped>
  .breadcrumb{
    padding: 10px 5px;
    padding-bottom: 5px;
    background: transparent;
  }
  .breadcrumb-item a,
  .breadcrumb-item{
    font-size: 20px;
  }
  .nav2{
    height: 100%;
    /*background: url("~@/assets/img/bg4.png") no-repeat;*/
    background-size: 100% auto;
    background-position: 0 -100px;
  }
  .content{
    padding-top: 8%;
  }
  .content ul{
    display: flex;
    flex-direction: row;
    justify-content: center;
  }
  .content ul li{
    list-style: none;
    display: inline;
  }
  .content ul li a{
    /*background: ;*/
    color: #4e555b;
    display: inline-block;
    margin: 40px;
    border-radius: 10px;
    width: 210px;
    height: 150px;
    font-size: 24px;
    font-weight: bold;
    /*box-shadow: 0 0 10px #95999c;*/
    border: 4px solid #7abaff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-decoration: none;
  }
  .content ul .info a{
    width: 240px;
    padding: 10px;
    color: #5a6268;
    font-weight: normal !important;
    text-align: left;
  }
  .content ul li a div{
    font-size: 16px;
    font-weight: normal;
    color: #95999c;
    font-weight: bold;

  }
</style>
